<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('检测机构仪器设备列表')" />
	<th:block th:include="include :: datetimepicker-css" />
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: datetimepicker-js" />
	<style>
		.lih{
			height: 30px;
		}
	</style>
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>

							<li>
								<p>设备名称:</p><input type="text" name="equipmentName"/>
							</li>
							<li>
								<p>设备编号:</p> <input type="text" name="equipmentNo"/>
							</li>
							<li>
								<p>是否校验:</p>
								<select class="" name="isCheck">
									<option value="" >--请选择--</option>
									<option value="1" >是</option>
									<option value="0" >否</option>
								</select>
							</li>
							<li class="lih">
								<p>检测证书编号:</p>
								<input type="text" name="certificateNum"/>
							</li>
<!--							<li style="height: 30px">-->
<!--								<p>有效期到期日期:</p>-->
<!--								<input type="date" name="validityEndDate"/>-->
<!--							</li>-->
							<li class="select-time"> <p>有效日期:</p>
								<input type="text" class="input-time" id="startTime" name="startTime"/> <span>-</span>
								<input type="text" class="input-time" id="endTime" name="endTime"/>
							</li>
<!--							<li class="lih">-->
<!--								<p >所属检测机构:</p>-->
<!--								<input type="text" name="agencyName"/>-->
<!--							</li>-->
							<li>
								<a class="btn btn-primary btn-rounded btn-sm m50"
								   onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.addTab()"
				   shiro:hasPermission="system:tJcJcjgJcyq:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled"
				   onclick="$.operate.editTab()" shiro:hasPermission="system:tJcJcjgJcyq:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:tJcJcjgJcyq:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="system:tJcJcjgJcyq:import">
					<i class="fa fa-upload"></i> 导入
				</a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:tJcJcjgJcyq:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:tJcJcjgJcyq:remove')}]];
        var detailFlag = [[${@permission.hasPermi('system:tJcJcjgJcyq:detail')}]];
        var prefix = ctx + "system/tJcJcjgJcyq";

        $(function() {
			var sdate=new Date().toLocaleString().split(" ")[0].split("/");
			if(sdate[1]<10){
				sdate[1]="0"+sdate[1]
			}
			if(sdate[2]<10){
				sdate[2]="0"+sdate[2]
			}
			$("#startTime").attr("placeholder",sdate.join("-"))
			addDay(30);
			function addDay(day){
				var dayTime=day*24*60*60*1000; //参数天数的时间戳
				var nowTime=new Date().getTime(); //当天的时间戳
				var t = new Date(nowTime+dayTime).toLocaleString().split(" "); //把两个时间戳转换成普通时间
				var eDate=t[0].split("/")
				if(eDate[1]<10){
					eDate[1]="0"+eDate[1]
				}
				if(eDate[2]<10){
					eDate[2]="0"+eDate[2]
				}

				console.log(eDate.join("-"))
				$("#endTime").attr("placeholder",eDate.join("-"))
			}
			$("#checkTime").datetimepicker({
				format: "yyyy-mm-dd",
				minView: "month",
				autoclose: true
			});
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
				detailUrl: prefix + "/detail/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
				importUrl: prefix + "/importData",
				importTemplateUrl: prefix + "/importTemplate",
                modalName: "检测机构仪器设备",
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'equipmentName',
					title : '设备名称',
					sortable: true
				},
				{
					field : 'equipmentNo', 
					title : '设备编号',
					sortable: true
				},

				// {
				// 	field : 'equipmentTypeNo',
				// 	title : '设备型号',
				// 	sortable: true,
				// 	visible:false
				// },
				{
					field : 'isCheck', 
					title : '是否校验',
					sortable: true,
					formatter: function(value, row, index) {
						if(value==1){
							return '是';
						}
						if(value==0){
							return '否';
						}
					}
				},
				{
					field : 'certificateNum',
					title : '检测证书编号',
					sortable: true
				},
				// {
				// 	field : 'checkResult',
				// 	title : '校验结果',
				// 	sortable: false
				// },
				// {
				// 	field : 'checkStation',
				// 	title : '校验单位',
				// 	sortable: true
				// },

				// {
				// 	field : 'checkTime',
				// 	title : '校验日期',
				// 	sortable: true,
				// 	visible:false
				// },
				{
					field : 'validityDate',
					title : '有效日期',
					sortable: true
				},
				{
					field : 'agencyName',
					title : '所属检测机构',
					sortable: true
				},
				// {
				// 	field : 'updateTime',
				// 	title : '操作时间',
				// 	sortable: false
				// },
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag +
								'" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.jcjgJcyqId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.jcjgJcyqId + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        actions.push('<a class="btn btn-warning btn-xs ' + detailFlag +
								'" href="javascript:void(0)" onclick="$.operate.detailFull(\'' + row.jcjgJcyqId + '\')"><i class="fa fa-search"></i>详情</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
    </script>
</body>
<script id="importTpl" type="text/template">
	<form enctype="multipart/form-data" class="mt20 mb10">
		<div class="col-xs-offset-1">
			<input type="file" id="file" name="file"/>
			<div class="mt10 pt5">
				<input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在，更新这条数据。"> 是否更新已经存在的用户数据
				&nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
			</div>
			<font color="red" class="pull-left mt10">
				提示：仅允许导入“xls”或“xlsx”格式文件！
			</font>
		</div>
	</form>
</script>
</html>